home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ahoy 1984 January to June
/
Ahoy_Magazine_84-Jan-Jun_1984_Double_L.d64
/
sequential file
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
1KB
|
52 lines
5 rem--ahoy!--jan issue--sequential files--prog page 67
10 clr:dimn$(100),p$(100):printchr$(147)
20 print" phone book sequential file demo"
100 print:print:print"start new file (y/n)? ";
110 geta$:ifa$<>"y"anda$<>"n"then110
120 ifa$="n"thenprint"no":goto200
130 print"yes":open2,8,2,"@0:phones,s,w"
140 print#2,"0":close2
200 open2,8,2,"phones,s,r":input#2,n
210 forx=1ton:input#2,n$(x),p$(x):next
220 close2
230 print"[147]";n;" entries exist in file"
300 print:print"1- add entries"
310 print"2- delete entries"
320 print"3- display list"
330 print"4- search for name"
340 print"5- exit program"
350 print:print"enter choice: ";
360 geta$:a=val(a$):ifa<1ora>5then360
370 ifa=1then400
375 ifa=2then450
380 ifa=3then500
385 ifa=4then550
390 ifa=5then600
400 printchr$(147);"enter name, phone number:":n$="":p$="":inputn$,p$
410 ifn$=""then230
420 n=n+1:n$(n)=n$:p$(n)=p$:goto230
450 printchr$(147);"enter name,to delete:":n$="":inputn$:ifn$=""then230
460 f=0:forx=1ton:ifn$=n$(x)thenf=x
470 next:iff<>0then480
472 print"not found. hit a key."
475 geta$:ifa$=""then475
477 goto230
480 n=n-1:forx=fton:n$(x)=n$(x+1):p$(x)=p$(x+1):next
490 goto230
500 printchr$(147)
510 forx=1ton:printn$(x),p$(x):next:print:print"all done. hit a key."
520 geta$:ifa$=""then520
530 goto230
550 printchr$(147);"enter name to search for:":n$="":inputn$:ifn$=""then230
560 f=0:forx=1ton:ifn$=n$(x)thenf=x
565 next
570 iff<>0then580
575 print"not found. hit a key."
577 geta$:ifa$=""then577
578 goto230
580 printn$(f),p$(f):print:print"hit a key."
585 geta$:ifa$=""then585
590 goto230
600 open2,8,2,"@0:phones,s,w":print#2,n
610 forx=1ton:print#2,n$(x):print#2,p$(x):next:close2